(function() {
  'use strict';
  angular
    .module('lighter')
    //paging用来对前端数据进行分页
    .filter('paging', paging)
    //size用来在页面中获取过滤后的数组长度
    .filter('size', size)
    //orderClass用来生成排序图标
    .filter('orderClass',orderClass);

    /** @ngInject */
    function paging() {
      return function (items, index, pageSize) {
        if (!items)
        return [];

        var offset = (index - 1) * pageSize;
        return items.slice(offset, offset + pageSize);
      }
    }

    function size() {
      return function (items) {
        if (!items)
        return 0;
        return items.length || 0
      }
    }

    function orderClass() {
      return function (direction) {
        if (direction === -1)
          return "glyphicon-chevron-down";
        else
          return "glyphicon-chevron-up";
      }
    }
})();